package com.dces.jx.billtest;
import com.dces.jx.billtest.config.MyBatisMapperScannerConfig;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Import;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import com.xdo.pcode.service.PCodeHolder;
import com.xdo.common.support.TokenUserHandlerMethodArgumentResolver;
import java.util.List;
/**
 * @author xdoV2.0
 * @date: 2021-9-7
 */
@EnableTransactionManagement
@SpringBootApplication
@Import({MyBatisMapperScannerConfig.class})
@EnableCaching
@ComponentScan({"com.dces.jx.billtest.**", "com.xdo.springboot.**", "com.xdo.mybatis.**"})
public class Application extends SpringBootServletInitializer implements WebMvcConfigurer {
    @Value("${dc.pcode.url}")
    private String pcodeUrl;
    @Bean
    public PCodeHolder getPCodeHolder() {
        PCodeHolder pCodeHolder = new PCodeHolder(pcodeUrl, new String[]{});
        return pCodeHolder;
    }
     @Override
    public void addArgumentResolvers(List<HandlerMethodArgumentResolver> resolvers) {
        resolvers.add(new TokenUserHandlerMethodArgumentResolver());
    }
    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
        return builder.sources(Application.class);
    }
    public static void main(String[] args) {
        SpringApplication.run(Application.class, args);
    }
}
